/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import com.wf.captcha.*;
import org.apache.commons.io.FileUtils;
import org.junit.Test;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

/**
 * <p>Project: javaseapp - Demo
 * <p>Powered by webrx On 2021-08-17 11:37:48
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class Demo {

    @Test
    public void m1() {
        System.out.println("Test Junit m1()");
    }

    @Test
    public void m2() {
        try {
            File src = new File("../dict");
            //System.out.println(src.exists());
            //System.out.println(src.isDirectory());
            File dst = new File("c:/mydict");
            //实现的目录复制
            FileUtils.copyDirectory(src, dst);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void m3() {
        //FileUtils
        //FilenameUtils.
        try {
            //删除目录
            //FileUtils.deleteDirectory(new File("dict"));
            FileUtils.deleteDirectory(new File("c:/mydict"));
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    @Test
    public void cc1() throws FileNotFoundException {
        // png类型
        SpecCaptcha captcha = new SpecCaptcha(130, 48);
        captcha.text();  // 获取验证码的字符
        captcha.textChar();  // 获取验证码的字符数组

        // gif类型
        var gif = new GifCaptcha(130, 48);
        gif.setLen(2);

        // 中文类型
        var cn = new ChineseCaptcha(130, 48);

        // 中文gif类型
        var cngif = new ChineseGifCaptcha(130, 48);

        // 算术类型
        var ari = new ArithmeticCaptcha(130, 48);
        ari.setLen(3);  // 几位数运算，默认是两位
        //captcha.getArithmeticString();  // 获取运算的公式：3+2=?
        //captcha.text();  // 获取运算的结果：5

        cn.out(new FileOutputStream("../dict/c2.png"));  // 输出验证码
    }
}
